﻿using SqlKata;
using SqlKataDemo.GraphQLApi.Services;

namespace SqlKataDemo.GraphQLApi.GraphTypes
{
    [ExtendObjectType(typeof(QueryType))]
    public class ProductResolver
    {
        public Product GetProduct([Service] IDbFactory dbFactory)
        {
            var query = new Query("product");
            var product = dbFactory.GetFactory().Get<Product>(query).FirstOrDefault();
            return product;
        }
    }

    public class Product
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
    }
}
